package com.specialtreasure.freightdepot.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.app.core.config.Constants;
import com.app.core.config.HttpApi;
import com.app.core.util.UserUtils;
import com.app.core.fragment.BaseNewFragment;
import com.app.core.util.CommonUtil;
import com.app.core.util.NumberUtil;
import com.app.core.view.MarqueeTextView;
import com.baidu.mapapi.model.LatLng;
import com.baidu.mapapi.search.core.SearchResult;
import com.baidu.mapapi.search.geocode.GeoCodeOption;
import com.baidu.mapapi.search.geocode.GeoCodeResult;
import com.baidu.mapapi.search.geocode.GeoCoder;
import com.baidu.mapapi.search.geocode.OnGetGeoCoderResultListener;
import com.baidu.mapapi.search.geocode.ReverseGeoCodeResult;
import com.baidu.mapapi.utils.DistanceUtil;
import com.specialtreasure.freightdepot.R;
import com.specialtreasure.freightdepot.activity.GoodsDetailsActivity;
import com.specialtreasure.freightdepot.model.Address;
import com.specialtreasure.freightdepot.model.BaseModel;
import com.specialtreasure.freightdepot.popupwindow.SelectCityPW;
import com.specialtreasure.freightdepot.popupwindow.SelectCityTwo;
import com.specialtreasure.freightdepot.popupwindow.SelectTruckPW;
import com.specialtreasure.freightdepot.popupwindow.SelectUnitPW;
import com.yanzhenjie.httpmodule.http.CallServer;
import com.yanzhenjie.httpmodule.http.Result;
import com.yanzhenjie.httpmodule.http.StringRequest;
import com.yanzhenjie.nohttp.Logger;
import com.yanzhenjie.nohttp.RequestMethod;
import com.yanzhenjie.nohttp.rest.CacheMode;
import com.yanzhenjie.nohttp.rest.Response;
import com.yanzhenjie.nohttp.rest.SimpleResponseListener;

import org.simple.eventbus.EventBus;

import java.util.ArrayList;
import java.util.List;

import static android.app.Activity.RESULT_OK;

/**
 * Created by Administrator on 2017/8/7 0007.
 * 发布页面v2
 */

public class PublicFragmentV2 extends BaseNewFragment implements View.OnClickListener {

    public static final String TAG = "PublicFragment";
    private TextView tv_title;//标题
    private TextView tv_sure;//清空
    private MarqueeTextView tv_navigation;//跑马灯
    private TextView tv_chufadi;//出发地文本
    private RelativeLayout rl_chufadi;//出发地点击
    private TextView tv_mudidi;//目的地文本
    private RelativeLayout rl_mudidi;//目的地点击事件
    private TextView tv_licheng;//里程
    private TextView tv_car_length_select;//车长选择
    private TextView tv_car_type_select;//车型选择
    private EditText et_goods_num;//货物数量
    private TextView tv_unit;//选择单个单位

    private TextView tv_goods_type_select;//货物类型
    private TextView tv_delivery_method_select;//发货方式选择
    private EditText et_goods_cost;//货物类型
    private TextView tv_unit_two;//选择多个单位
    private RelativeLayout rl_goods;//点击货物详细信息
    private TextView tv_autotext;//自动输入详细信息

    private Button btn_public_history;//发布历史
    private Button btn_sure_public;//确认发布
    private LinearLayout ll_root;
    private RelativeLayout rl_goods_type;
    private RelativeLayout rl_car_type;
    private RelativeLayout rl_delivery_method;
    private RelativeLayout rl_car_length;
    private EditText et_car_num;

    private String startProvinceAddress;//出发地(省)
    private String startCityAddress;//出发地(市)
    private String startCountyAddress;//出发地(县)
    private String chufadi;

    private String destProvinceAddress;//目的地(省)
    private String destCityAddress;//目的地(市)
    private String destCountyAddress;//目的地(县)
    private String mudidi;
    Integer userType;//1.发送给车队 2.发给同行

    private String carLength;//车长
    private String carType;//车型
    private String content;//自动生成的信息
    private String goodsType;//货物类型
    private String deliveryMethod;//发货方式

    private String unit = "吨";//吨
    private String unit2 = "元/吨";//元/吨
    long goodsTrans;

    private long collectionStatue = 0;//代收货款 0否 1是
    String photo1;//照片1
    String photo2;//照片2
    String itemDetailArr;//货物清单: (json格式List(ItemDetailResp))
    String loadingAddress;//装货地址
    String unloadingAddress;//卸货地址
    String collectionMoneyStr;//代收款金额

    private LatLng mFrom;
    private LatLng mTo;
    private double distance;
    private GeoCoder mSearch;


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = View.inflate(mContext, R.layout.frag_publish_v2, null);
        initView(view);
        return view;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        setData();
        getAD();
    }

    private void setData() {
        tv_title.setText("发布");
        tv_sure.setText("清空");
        show(tv_sure);
        tv_sure.setTextColor(mContext.getResources().getColor(R.color.common_FD4141));


        //限制小数点
        NumberUtil.setEditTextPoint(et_goods_cost, 1);

        //监听edittext输入
        et_goods_num.addTextChangedListener(textWatcher);//货物数量
        et_goods_cost.addTextChangedListener(textWatcher);//货物运费
        et_car_num.addTextChangedListener(textWatcher);//车数量


        mSearch = GeoCoder.newInstance();

    }

    /**
     * edittext监听
     */
    private TextWatcher textWatcher = new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void afterTextChanged(Editable editable) {
            autoText();

        }
    };


    @Override
    protected String getFragmentName() {
        return TAG;
    }

    private void initView(View view) {
        tv_title = (TextView) view.findViewById(R.id.tv_title);
        tv_navigation = (MarqueeTextView) view.findViewById(R.id.tv_navigation);
        tv_chufadi = (TextView) view.findViewById(R.id.tv_chufadi);
        rl_chufadi = (RelativeLayout) view.findViewById(R.id.rl_chufadi);
        rl_chufadi.setOnClickListener(this);
        tv_mudidi = (TextView) view.findViewById(R.id.tv_mudidi);
        rl_mudidi = (RelativeLayout) view.findViewById(R.id.rl_mudidi);
        rl_mudidi.setOnClickListener(this);
        tv_licheng = (TextView) view.findViewById(R.id.tv_licheng);
        tv_car_length_select = (TextView) view.findViewById(R.id.tv_car_length_select);
        tv_car_type_select = (TextView) view.findViewById(R.id.tv_car_type_select);
        et_goods_num = (EditText) view.findViewById(R.id.et_goods_num);

        tv_goods_type_select = (TextView) view.findViewById(R.id.tv_goods_type_select);
        tv_delivery_method_select = (TextView) view.findViewById(R.id.tv_delivery_method_select);
        et_goods_cost = (EditText) view.findViewById(R.id.et_goods_cost);
        rl_goods = (RelativeLayout) view.findViewById(R.id.rl_goods);
        rl_goods.setOnClickListener(this);

        btn_public_history = (Button) view.findViewById(R.id.btn_public_history);
        btn_public_history.setOnClickListener(this);
        btn_sure_public = (Button) view.findViewById(R.id.btn_sure_public);
        btn_sure_public.setOnClickListener(this);
        tv_unit = (TextView) view.findViewById(R.id.tv_unit);
        tv_unit_two = (TextView) view.findViewById(R.id.tv_unit_two);
        tv_autotext = (TextView) view.findViewById(R.id.tv_autotext);
        ll_root = (LinearLayout) view.findViewById(R.id.ll_root);
        rl_goods_type = (RelativeLayout) view.findViewById(R.id.rl_goods_type);
        rl_car_type = (RelativeLayout) view.findViewById(R.id.rl_car_type);
        rl_delivery_method = (RelativeLayout) view.findViewById(R.id.rl_delivery_method);
        rl_car_length = (RelativeLayout) view.findViewById(R.id.rl_car_length);
        et_car_num = (EditText) view.findViewById(R.id.et_car_num);
        tv_sure = (TextView) view.findViewById(R.id.tv_sure);

        tv_unit.setOnClickListener(this);
        tv_unit_two.setOnClickListener(this);
        rl_goods_type.setOnClickListener(this);
        rl_car_type.setOnClickListener(this);
        rl_delivery_method.setOnClickListener(this);
        rl_car_length.setOnClickListener(this);
        tv_sure.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_sure:
                CommonUtil.hideIputKeyboard(getActivity());
                clearText();
                break;
            case R.id.btn_public_history://发送给车队
                userType = 1;
                submit();
                break;
            case R.id.btn_sure_public://发送给同行
                userType = 2;
                submit();
                break;
            case R.id.rl_goods://跳转到货物详情页
                intent.setClass(mContext, GoodsDetailsActivity.class);
                startActivityForResult(intent, Constants.ONE);
                break;
            case R.id.rl_chufadi://出发地
                SelectCityTwo pwTo = new SelectCityTwo(getActivity());
                pwTo.showAtBottom(ll_root);
                pwTo.setOnResultListener(new SelectCityTwo.OnResultListener() {
                    @Override
                    public void onResult(Address address) {
                        if (address != null) {
                            startProvinceAddress = address.province;
                            startCityAddress = address.city;
                            startCountyAddress = address.region;
                            //判断省和市
                            if (startProvinceAddress==startCityAddress ){
                                startProvinceAddress="";
                            }
                            chufadi = startProvinceAddress+ startCityAddress+ startCountyAddress;
                            tv_chufadi.setText(chufadi);
                            autoText();

                            mSearch.setOnGetGeoCodeResultListener(new OnGetGeoCoderResultListener() {
                                @Override
                                public void onGetGeoCodeResult(GeoCodeResult geoCodeResult) {
                                    if (geoCodeResult == null || geoCodeResult.error != SearchResult.ERRORNO.NO_ERROR) {
                                        //没有检索到结果
                                        mFrom = null;
                                        caculateDistance();
                                        return;
                                    }
                                    mFrom = geoCodeResult.getLocation();
                                    caculateDistance();
                                }

                                @Override
                                public void onGetReverseGeoCodeResult(ReverseGeoCodeResult reverseGeoCodeResult) {
                                }
                            });
                            mSearch.geocode(new GeoCodeOption().city(address.city).address(TextUtils.isEmpty(address.region) ? address.city : address.region));
                        }

                    }


                });
                break;
            case R.id.rl_mudidi://目的地
                SelectCityTwo pwTo2 = new SelectCityTwo(getActivity());
                pwTo2.showAtBottom(ll_root);
                pwTo2.setOnResultListener(new SelectCityTwo.OnResultListener() {
                    @Override
                    public void onResult(Address address) {
                        if (address != null) {
                            destProvinceAddress = address.province;
                            destCityAddress = address.city;
                            destCountyAddress = address.region;
                            //判断省和市
                            if (destProvinceAddress==destCityAddress ){
                                destProvinceAddress="";
                            }
                            mudidi = destProvinceAddress + destCityAddress + destCountyAddress;
                            tv_mudidi.setText(mudidi);
                            autoText();
                            mSearch.setOnGetGeoCodeResultListener(new OnGetGeoCoderResultListener() {
                                @Override
                                public void onGetGeoCodeResult(GeoCodeResult geoCodeResult) {
                                    if (geoCodeResult == null || geoCodeResult.error != SearchResult.ERRORNO.NO_ERROR) {
                                        //没有检索到结果
                                        mTo = null;
                                        caculateDistance();
                                        return;
                                    }
                                    //获取地理编码结果
                                    mTo = geoCodeResult.getLocation();
                                    caculateDistance();
                                }

                                @Override
                                public void onGetReverseGeoCodeResult(ReverseGeoCodeResult reverseGeoCodeResult) {

                                }
                            });
                            mSearch.geocode(new GeoCodeOption().city(address.city).address(TextUtils.isEmpty(address.region) ? address.city : address.region));
                        }
                    }
                });
                break;
            case R.id.rl_car_length://车长选择
                SelectTruckPW supw = new SelectTruckPW(getActivity(),"1");
                supw.showAtBottom(ll_root);
                supw.setOnResultListener(new SelectTruckPW.OnResultListener() {
                    @Override
                    public void onResult(String str) {
                        if (!TextUtils.isEmpty(str)) {
                            tv_car_length_select.setText(str);
                            tv_car_length_select.setTextColor(mContext.getResources().getColor(R.color.common_474747));
                            carLength = str;

//                            if (carLength.equals("不限")){
//                                carLength=null;
//                            }
                            autoText();
                        }
                    }
                });
                break;
            case R.id.rl_car_type://车型选择
                SelectUnitPW supw1 = new SelectUnitPW(getActivity(), "chexing.xml", "车型");
                supw1.showAtBottom(ll_root);
                supw1.setOnResultListener(new SelectUnitPW.OnResultListener() {
                    @Override
                    public void onResult(String str) {
                        if (!TextUtils.isEmpty(str)) {
                            tv_car_type_select.setText(str);
                            tv_car_type_select.setTextColor(mContext.getResources().getColor(R.color.common_474747));
                            carType = str;

//                            if (carType.equals("不限")){
//                                carType=null;
//                            }
                            autoText();
                        }
                    }
                });
                break;
            case R.id.rl_goods_type://货物类型
                SelectUnitPW supw2 = new SelectUnitPW(getActivity(), "huowuleixing.xml", "货物类型");
                supw2.showAtBottom(ll_root);
                supw2.setOnResultListener(new SelectUnitPW.OnResultListener() {
                    @Override
                    public void onResult(String str) {
                        if (!TextUtils.isEmpty(str)) {
                            tv_goods_type_select.setText(str);
                            tv_goods_type_select.setTextColor(mContext.getResources().getColor(R.color.common_474747));
                            goodsType = str;
                            autoText();
                        }
                    }
                });
                break;
            case R.id.rl_delivery_method://发货方式
                SelectUnitPW supw3 = new SelectUnitPW(getActivity(), "zhaunghuofangshi.xml", "发货方式");
                supw3.showAtBottom(ll_root);
                supw3.setOnResultListener(new SelectUnitPW.OnResultListener() {
                    @Override
                    public void onResult(String str) {
                        if (!TextUtils.isEmpty(str)) {
                            tv_delivery_method_select.setText(str);
                            tv_delivery_method_select.setTextColor(mContext.getResources().getColor(R.color.common_474747));
                            deliveryMethod = str;
                            autoText();
                        }
                    }
                });
                break;
            case R.id.tv_unit://选择单位单个
                SelectUnitPW supw4 = new SelectUnitPW(getActivity(), "huowushuliang.xml", "单位");
                supw4.showAtBottom(ll_root);
                supw4.setOnResultListener(new SelectUnitPW.OnResultListener() {
                    @Override
                    public void onResult(String str) {
                        if (!TextUtils.isEmpty(str)) {
                            tv_unit.setText(str);
                            unit = str;
                            autoText();
                        }
                    }
                });
                break;
            case R.id.tv_unit_two://选择多个单位
                SelectUnitPW supw5 = new SelectUnitPW(getActivity(), "huowushuliang.xml", "单位");
                supw5.showAtBottom(ll_root);
                supw5.setOnResultListener(new SelectUnitPW.OnResultListener() {
                    @Override
                    public void onResult(String str) {
                        if (!TextUtils.isEmpty(str)) {
                            tv_unit_two.setText("元/" + str);
                            unit2 = "元/" + str;
                            autoText();
                        }
                    }
                });
                break;

        }
    }

    private void submit() {
        // validate
        if (TextUtils.isEmpty(chufadi)) {
            Toast.makeText(mContext, "出发地不能为空", Toast.LENGTH_SHORT).show();
            return;
        }

        if (TextUtils.isEmpty(mudidi)) {
            Toast.makeText(mContext, "到达地不能为空", Toast.LENGTH_SHORT).show();
            return;
        }

        if (TextUtils.isEmpty(carLength)) {
            Toast.makeText(mContext, "车长不能为空", Toast.LENGTH_SHORT).show();
            return;
        }

        if (TextUtils.isEmpty(carType)) {
            Toast.makeText(mContext, "车型不能为空", Toast.LENGTH_SHORT).show();
            return;
        }

        // TODO validate success, do something
        showDialog(Constants.LOADING);
        getData();

    }

    private void getData() {
        String url = Constants.HTTP_URL + HttpApi.PUSHITEM;
        StringRequest request = new StringRequest(url, RequestMethod.POST);
        request.add("token", UserUtils.getToken());
        request.addNull("startProvinceAddress", startProvinceAddress);
        request.addNull("startCityAddress", startCityAddress);
        request.addNull("startCountyAddress", startCountyAddress);
        request.addNull("destProvinceAddress", destProvinceAddress);
        request.addNull("destCityAddress", destCityAddress);
        request.addNull("destCountyAddress", destCountyAddress);
        request.addNull("carLength", carLength);
        request.addNull("carType", carType);
        request.addNull("content", content);
        request.addNull("userType", userType);

        request.addNull("goodsNum", et_goods_num.getText().toString().trim() + unit);
        request.addNull("goodsType", goodsType);
        request.addNull("sendStyle", deliveryMethod);

        String goodsCost=et_goods_cost.getText().toString().trim();
        if (!TextUtils.isEmpty(goodsCost)){
            goodsTrans=Long.parseLong(goodsCost);
            request.add("goodsTrans", goodsTrans);
        }
        request.addNull("goodsTransStr", unit2);
        request.addNull("carNum", et_car_num.getText().toString().trim());

        request.addNull("collectionStatue", collectionStatue);
        request.addNull("loadingAddress", loadingAddress);
        request.addNull("unloadingAddress", unloadingAddress);
        request.addNull("collectionMoneyStr", collectionMoneyStr);
        request.addNull("itemDetailArr", itemDetailArr);
        request.addNull("photo1", photo1);
        request.addNull("photo2", photo2);


        request.setCacheMode(CacheMode.ONLY_REQUEST_NETWORK);
        CallServer.getInstance().request(Constants.ZERO, request, new SimpleResponseListener<Result<String>>() {
            @Override
            public void onSucceed(int what, Response<Result<String>> response) {
                super.onSucceed(what, response);
                closeDialog();

                String result = response.get().getResult();
                Logger.e("请求成功：" + result);
                BaseModel baseModel = JSON.parseObject(result, BaseModel.class);
                if (baseModel != null) {
                    Integer status = baseModel.getStatus();
                    String msg = baseModel.getMsg();
                    if (status != null && status == 0) {
                        //更新信息管理
//                        if (userType==1){//车队
//                            EventBus.getDefault().post(new BaseModel(), Constants.UPDATEPUBLIC);
//                        }else {//同行 mq
//
//                        }
                        EventBus.getDefault().post(new BaseModel(), Constants.UPDATEPUBLIC);

                        clearText();
                        Toast.makeText(mContext, "发布成功", Toast.LENGTH_SHORT).show();
                    } else {
                        Toast.makeText(mContext, msg, Toast.LENGTH_SHORT).show();
                    }
                }


            }
        });

    }

    /**
     * 获取广告
     */
    private void getAD(){
        String url = Constants.HTTP_URL + HttpApi.ADVERTLIST;
        StringRequest request = new StringRequest(url, RequestMethod.POST);

        request.setCacheMode(CacheMode.ONLY_REQUEST_NETWORK);

        CallServer.getInstance().request(Constants.ONE, request, new SimpleResponseListener<Result<String>>() {
            @Override
            public void onSucceed(int what, Response<Result<String>> response) {
                super.onSucceed(what, response);
                closeDialog();

                String result = response.get().getResult();
                Logger.e("请求成功：" + result);

                JSONObject jsonObject = JSON.parseObject(result);
                if (jsonObject != null) {
                    Integer status = jsonObject.getInteger("status");
                    String msg = jsonObject.getString("msg");

                    if (status != null && status == 0) {
                        List<String> data = JSON.parseArray(jsonObject.getJSONArray("data").toString(), String.class);
                        if (data != null&& data.size()>0) {
                            tv_navigation.init(data);
                        }

                    } else {
                        Toast.makeText(mContext, msg, Toast.LENGTH_SHORT).show();

                    }

                }

            }


        });
    }


    /**
     * 自动输入信息
     */
    private void autoText() {
        StringBuilder builder = new StringBuilder();
        if (!"出发地".equals(tv_chufadi.getText().toString())) {
            builder.append(tv_chufadi.getText().toString());
            builder.append("->");
        }

        if (!"到达地".equals(tv_mudidi.getText().toString())) {
            builder.append(tv_mudidi.getText().toString());
            builder.append(",");
        }

        //货物类型
        if (!TextUtils.isEmpty(goodsType)) {
            builder.append("有");
            builder.append(goodsType);
        }
        //货物数量
        if (!TextUtils.isEmpty(et_goods_num.getText().toString())) {
            builder.append(et_goods_num.getText().toString());
            builder.append(unit);
            builder.append(",");
        }
        //车长
        if (!TextUtils.isEmpty(carLength)) {
            if (carLength.equals("不限")){
                carLength="不限";
            }else {
                builder.append("求");
                builder.append(carLength);
            }

        }
        //车型
        if (!TextUtils.isEmpty(carType)) {
            if (carType.equals("不限")){
                carType="不限";
            }else {
                builder.append(carType);
            }


        }
        //车辆数量
        if (!TextUtils.isEmpty(et_car_num.getText().toString())) {
            builder.append(et_car_num.getText().toString());
            builder.append("辆");
            builder.append(",");
        }

        //货物运费
        if (!TextUtils.isEmpty(et_goods_cost.getText().toString())) {
            builder.append(et_goods_cost.getText().toString());
            builder.append(unit2);
            builder.append(",");
        }
        //发货方式
        if (!TextUtils.isEmpty(deliveryMethod)) {
            builder.append(deliveryMethod);
        }
        //自动输入
        tv_autotext.setTextColor(mContext.getResources().getColor(R.color.common_474747));
        content = builder.toString();
        tv_autotext.setText(builder.toString());
    }

    /**
     * 清空文本数据
     */
    private void clearText() {
        et_car_num.getText().clear();
        et_goods_cost.getText().clear();
        et_goods_num.getText().clear();

        tv_chufadi.setText("出发地");
        tv_mudidi.setText("到达地");

        tv_goods_type_select.setText("请选择货物类型");
        tv_goods_type_select.setTextColor(mContext.getResources().getColor(R.color.common_a9a9a9));
        tv_car_length_select.setText("请选择车长");
        tv_car_length_select.setTextColor(mContext.getResources().getColor(R.color.common_a9a9a9));
        tv_car_type_select.setText("请选择车型");
        tv_car_type_select.setTextColor(mContext.getResources().getColor(R.color.common_a9a9a9));
        tv_delivery_method_select.setText("请选择发货类型");
        tv_delivery_method_select.setTextColor(mContext.getResources().getColor(R.color.common_a9a9a9));

        tv_licheng.setText("里程：0km");
        tv_autotext.setText("");
        tv_autotext.setTextColor(mContext.getResources().getColor(R.color.common_a9a9a9));

        chufadi=null;
        mudidi=null;

        carLength=null;
        carType=null;
        content=null;
        userType=null;
        goodsType=null;
        deliveryMethod=null;
        loadingAddress=null;
        unloadingAddress=null;
        collectionMoneyStr=null;
        itemDetailArr=null;
        photo1=null;
        photo2=null;

        mFrom=null;
        mTo=null;
        distance=0;





    }


    /**
     * 计算公里数
     */
    private void caculateDistance() {
        if (mFrom != null && mTo != null) {
            distance = CommonUtil.changeDouble(DistanceUtil.getDistance(mFrom, mTo) / 1000);
            tv_licheng.setText("里程：" + distance + "公里");
            return;
        }
        distance = 0;
        tv_licheng.setText("里程：" + distance + "公里");
    }


    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == Constants.ONE) {
            if (resultCode == RESULT_OK) {
                Logger.e("onActivityResult进来了");

                collectionStatue = data.getLongExtra("collectionStatue", 0);
                loadingAddress = data.getStringExtra("loadingAddress");
                unloadingAddress = data.getStringExtra("unloadingAddress");
                collectionMoneyStr = data.getStringExtra("collectionMoneyStr");
                itemDetailArr = data.getStringExtra("itemDetailArr");
                photo1 = data.getStringExtra("photo1");
                photo2 = data.getStringExtra("photo2");

            }

        }
    }
}
